import 'dart:ui';
import 'package:flutter/material.dart';

class ColorsUtil {
  static Color mainColor = const Color.fromRGBO(227, 180, 116, 1);
  static Color appBarColor = Colors.white;
  static Color bgColor = Colors.white;
  static Color unCheck = const Color.fromRGBO(153, 153, 153, 1);
}

Color hexColor(String hexColor, [double alpha = 1]) {
  hexColor = hexColor.toUpperCase().replaceAll('#', '');

  if (alpha < 0) {
    alpha = 0;
  } else if (alpha > 1) {
    alpha = 1;
  }
  if (hexColor.length == 6) {
    hexColor = '0xff' + hexColor;
  }
  // 先分别获取色值的RGB通道
  Color color = Color(int.parse(hexColor));
  int red = color.red;
  int green = color.green;
  int blue = color.blue;
  // 通过fromRGBO返回带透明度和RGB值的颜色
  return Color.fromRGBO(red, green, blue, alpha);
}
